import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../Layout/Layout.vue'
import Login from '../views/Login.vue'

const routes = [
  {
    //默认路由地址为Layout
    path: '/',
    name: 'Layout',
    component: Layout,
    //重定向设置路由跳转,当访问'/'时自动跳转到'/home'
    redirect:"/user",
    //嵌套子路由 主体区域展示
    children:[
      {
        path:"user",
        name:"User",
        component:() => import("@/views/User")
      },
      {
        path:"book",
        name:"Book",
        component:() => import("@/views/Book")
      },
      {
        path:"news",
        name:"News",
        component:() => import("@/views/News")
      },
      {
        path:"person",
        name:"Person",
        component:() => import("@/views/Person")
      },
    ]
  },

  {
    path: '/login',
    name: 'Login',
    component: () => import("@/views/Login")
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import("@/views/Register")
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
